package com.yohann.oss.controller;

import com.yohann.commonutils.result.R;
import com.yohann.oss.service.OssService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * <p>
 * oss服务控制器
 * </p>
 *
 * @author Yohann
 * @since 2020/8/7
 */
@RestController
@RequestMapping("/oss-service/oss")
public class OssController {

    @Autowired
    private OssService ossService;

    /**
     * 上传头像
     * @param file
     * @return
     */
    @PostMapping
    public R uploadOssFile(MultipartFile file){
        String url = ossService.uploadFileAvatar(file);

        return R.ok().data("url",url);
    }
}